package org.xx.armory.swing.builders;

import org.xx.armory.objectparser.ParsedObjectBuilder;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

public class MenuBarModelBuilder
        extends ParsedObjectBuilder<MenuBarModel> {
    private List<MenuModel> menus;

    public MenuBarModelBuilder() {
        this.menus = new ArrayList<>();
    }

    public void addMenu(
            MenuModel menu
    ) {
        this.menus.add(menu);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public MenuBarModel build() {
        return new MenuBarModel(getLineInfo(),
                                this.menus.stream().filter(Objects::nonNull).collect(Collectors.toList()));
    }
}
